<template>
    <view class="bottomMenu">
        <u-tabbar :value="value" @change="changeIndex" :placeholder="false" :safeAreaInsetBottom="true">
            <u-tabbar-item text="首页" icon="home" @click="gotoHome"></u-tabbar-item>
            <u-tabbar-item text="我的" icon="account" @click="gotoUser"></u-tabbar-item>
        </u-tabbar>
    </view>
</template>

<script>
import store from '../../store/index'
export default {
    props: {
        activityIndex: {
            type: Number,
            default: 0
        },
        // curRoute: {
        //     type: String,
        //     default: ''
        // }
    },
    data() {
        return {
            value: 0,
            curRoute: null
        }
    },
    computed: {
        hasLogin() {
            return this.$store.state.token && this.$store.state.token.length > 0;
        }
    },
    methods: {
        changeIndex(val) {
            console.log(val);

        },
        /**
         * 跳转到住页
         */
        gotoHome() {
            console.log(this.curRoute, 'curRoute');

            if (this.curRoute == 'pages/home/index') {
                return
            }
            uni.redirectTo({
                url: '/pages/home/index',
            })

        },
        /**
         * 跳转到用户页面
         */
        gotoUser() {
            if (this.curRoute == 'pages/user/index') {
                return
            }
            uni.redirectTo({
                url: '/pages/user/index',
            })
        },

    },
    mounted() {
        this.value = this.activityIndex;
        let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
        this.curRoute = routes[routes.length - 1].route
    },

}
</script>

<style lang="scss" scoped></style>